<?php

/**
 * TestDb: connect to unit-test database
 *
 * @author vbolshov
 */

class TestDb {
	static private $pdo;
	/**
	 * @return PDO
	 */
	static function connect()
	{
		if (self::$pdo)
		{
			return self::$pdo;
		}
		
		include dirname(__FILE__) . '/setup.php';
		
		return self::$pdo = new PDO(
			$settings['db']['dsn'], 
			$settings['db']['username'], 
			$settings['db']['password'],
			array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)
		);
	}
}